import { createSlice } from '@reduxjs/toolkit'


export const xinS = createSlice({
  name: 'xin',
  initialState:{
    xin:[
        {
            id:'1',
            name:'张三',
            code:'123612'
        },
        {
            id:'2',
            name:'李四',
            code:'6534415234'
        }
    ]
  },
  reducers: {
    shanchu:(state,action)=>{
        state.xin=state.xin.filter(v=>v.id!=action.payload)
    },
    tianjia:(state,action)=>{
        state.xin.push({
            ...action.payload,
            id:new Date().getDate()
        })
    }

    
  },
})


export const { shanchu , tianjia } = xinS.actions

